<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="css/login.css" rel="stylesheet" />
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="js/login.js"></script>
    <title>注册</title>
    <script src="js/layer/layer.js"></script>
</head>

<body>
    <div>
        <div id="header">
            <img class="back" src="images/back.png" alt="">
        </div>
        <div id="content">
            <div id="fp">
                <strong>手机注册</strong>
            </div>
            <div id="code">
                <img src="images/icon.png" alt="">
                <span>国家或地区注册后不能修改</span>
            </div>
            <form action="" id="form3" class="for">
                <!--<select name="" id="country">-->
                <!--<option value="">国家</option>-->
                <!--</select>-->
                <select name="" id="area">
                    <option value="">+86</option>
                </select>
                <input type="text" id="tell" class="int" placeholder="手机号码">
                <div id="msg"></div>
            </form>
            <div id="button">
                <button class="login" onclick="next()">下一步</button>
            </div>

        </div>

    </div>

    <script>
        $(function () {
            localStorage.top = "http://grandcoinage.co/";
            $(".back").click(function () {
                $(window).attr('location', "login.html");
            });

            // $(".login").click(function(){
            //     $(window).attr('location',"register_VertificationCode.html");
            // });
        })
    </script>
    <script>
        // 参数
        function GetRequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
                localStorage.invite_code = theRequest.invite_code;
                console.log(localStorage.invite_code);
            }
            return theRequest;
        }

        var Request = new Object();
        Request = GetRequest();


        function next() {
            var mobile = $("#tell").val();
            console.log(mobile);

            $.ajax({
                type: 'POST',
                url: `${localStorage.top}api/user/checkPhone`,
                data: {
                    mobile: $("#tell").val(),
                },
                success: function (data) {
                    console.log(data);
                    if (data.code == 0) {
                        layer.msg(data.msg);
                        // $("#msg").html(data.msg)
                    } else {
                        $("#msg").html(data.msg)
                        $(window).attr('location', "register_VertificationCode.html");
                        localStorage.mobile = mobile;
                        // console.log(mobile);
                    }
                }
            });
        }
    </script>
</body>

</html>